<html>
<head><meta charset="utf-8"><title>Changing CHALK_SOLVER_MAX_SIZE · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html">Changing CHALK_SOLVER_MAX_SIZE</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="184862092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184862092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184862092">(Jan 05 2020 at 19:51)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> <span class="user-mention" data-user-id="116009">@nikomatsakis</span> So, I know it's been discussed already a few times, but I really think the SLG <code>max_size</code> should be changed from 4 to probably 10. (Relevant line here <a href="https://github.com/rust-analyzer/rust-analyzer/blob/ce07a2daa9e53aa86a769f8641b14c2878444fbc/crates/ra_hir_ty/src/traits.rs#L59" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/blob/ce07a2daa9e53aa86a769f8641b14c2878444fbc/crates/ra_hir_ty/src/traits.rs#L59">https://github.com/rust-analyzer/rust-analyzer/blob/ce07a2daa9e53aa86a769f8641b14c2878444fbc/crates/ra_hir_ty/src/traits.rs#L59</a>)</p>



<a name="184862146"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184862146" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184862146">(Jan 05 2020 at 19:52)</a>:</h4>
<p>But, thinking about this made me think about how we would profile this</p>



<a name="184862163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184862163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184862163">(Jan 05 2020 at 19:53)</a>:</h4>
<p>Like, it would be simple enough to make the change. But the question is about those "edge cases" mentioned in the comment for that const</p>



<a name="184862217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184862217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184862217">(Jan 05 2020 at 19:54)</a>:</h4>
<p>However, I think changing it to 10 may mask/fix some errors, such as <a href="https://github.com/rust-lang/chalk/issues/302" target="_blank" title="https://github.com/rust-lang/chalk/issues/302">https://github.com/rust-lang/chalk/issues/302</a> and <a href="https://github.com/rust-lang/chalk/issues/301" target="_blank" title="https://github.com/rust-lang/chalk/issues/301">https://github.com/rust-lang/chalk/issues/301</a></p>



<a name="184862694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184862694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184862694">(Jan 05 2020 at 20:08)</a>:</h4>
<p>I think last time I tried to change it back to 10, it still lead to analysis hanging seemingly forever when running RA on itself</p>



<a name="184862840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184862840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184862840">(Jan 05 2020 at 20:12)</a>:</h4>
<p>How long ago was that?</p>



<a name="184862849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184862849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184862849">(Jan 05 2020 at 20:13)</a>:</h4>
<p>Also, changing it to 5 or 6 might also solve some problems too</p>



<a name="184862902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184862902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184862902">(Jan 05 2020 at 20:14)</a>:</h4>
<p>(this is probably more of a discussion for a wg-traits topic, but) I think <code>max_size</code> is probably <em>not</em> the right way of limiting run time</p>



<a name="184862910"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184862910" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184862910">(Jan 05 2020 at 20:14)</a>:</h4>
<p>(obviously, this has been thought about before with the idea of fuel)</p>



<a name="184862989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184862989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184862989">(Jan 05 2020 at 20:17)</a>:</h4>
<p>Right now, as long as everything is "making progress" in terms of finding answers to strands, Chalk will keep going and won't yield with <code>QuantumExceeded</code> (except for <code>PositiveCycle</code>s, which sort of have to continue currently). But once a table flounders, or there are no more solutions to a strand, it should yield with <code>QuantumExceeded</code>. The problem though right now, is that actually doesn't do anything, since <code>ForestSolver</code> just loops</p>



<a name="184863032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184863032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184863032">(Jan 05 2020 at 20:18)</a>:</h4>
<p>Probably want to think about allowing the caller to stop solving on <code>QuantumExceeded</code>, and if so, give some sort of "best guess" for an answer</p>



<a name="184863474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184863474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184863474">(Jan 05 2020 at 20:30)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/pull/2290" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/pull/2290">https://github.com/rust-analyzer/rust-analyzer/pull/2290</a></p>



<a name="184863500"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184863500" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184863500">(Jan 05 2020 at 20:31)</a>:</h4>
<p>I can try out what happens</p>



<a name="184863658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184863658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184863658">(Jan 05 2020 at 20:35)</a>:</h4>
<p>I don't think we've done anything since then that should make it not hang if it hung with 5 then</p>



<a name="184863709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184863709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184863709">(Jan 05 2020 at 20:36)</a>:</h4>
<p>I'm definitely interested to know if Chalk is yielding with <code>QuantumExceeded</code> during those hangs at any more</p>



<a name="184863717"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184863717" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184863717">(Jan 05 2020 at 20:37)</a>:</h4>
<p>Oh wait, maybe the hang for that issue is the old bug?</p>



<a name="184863721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184863721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184863721">(Jan 05 2020 at 20:37)</a>:</h4>
<p>maybe, maybe not</p>



<a name="184864153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184864153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184864153">(Jan 05 2020 at 20:49)</a>:</h4>
<p>currently, with 4 it crashes with "New answer was not ambiguous whereas previous answer was", with 5 it goes through, with 6-8 it crashes, with 9-10 it hangs</p>



<a name="184864242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184864242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184864242">(Jan 05 2020 at 20:51)</a>:</h4>
<p>('it hangs' doesn't necessarily mean it hangs forever, I only waited a few minutes)</p>



<a name="184864306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184864306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184864306">(Jan 05 2020 at 20:53)</a>:</h4>
<p>you can try this yourself (and see the Chalk debug logs) by setting the solver size to 9 or 10 and doing <code>cargo build --release -p ra_cli; CHALK_DEBUG=1 ./target/release/ra_cli analysis-stats . -o trait_solve_query</code></p>



<a name="184864320"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184864320" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184864320">(Jan 05 2020 at 20:53)</a>:</h4>
<p>(kind of ironically, <code>trait_solve_query</code> is the function where the analysis hangs)</p>



<a name="184864447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184864447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184864447">(Jan 05 2020 at 20:56)</a>:</h4>
<p>It's actually kind of interesting that 5 is fine but 6-8 crashes</p>



<a name="184913784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184913784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184913784">(Jan 06 2020 at 15:09)</a>:</h4>
<p>interesting</p>



<a name="184913924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184913924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184913924">(Jan 06 2020 at 15:10)</a>:</h4>
<p>I agree that upping the limit is good; I've been contemplating whether we should consider an alternative design for the chalk engine itself, or at least experiment with a few more. But I guess we have to first identify where the problems arise. I see a lot of chatter in <a class="stream" data-stream-id="144729" href="/#narrow/stream/144729-wg-traits">#wg-traits</a> so probably best to take it to a topic over there</p>



<a name="184939188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184939188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184939188">(Jan 06 2020 at 19:47)</a>:</h4>
<blockquote>
<p>Right now, as long as everything is "making progress" in terms of finding answers to strands, Chalk will keep going and won't yield with <code>QuantumExceeded</code> (except for <code>PositiveCycle</code>s, which sort of have to continue currently). But once a table flounders, or there are no more solutions to a strand, it should yield with <code>QuantumExceeded</code>. The problem though right now, is that actually doesn't do anything, since <code>ForestSolver</code> just loops</p>
</blockquote>
<p>btw what I had expected to do was to propagate <code>QunatumExceeded</code> back out through <code>ForestSolver</code>, I think, so that rust-analyzer could choose how much to loop</p>



<a name="184939242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184939242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184939242">(Jan 06 2020 at 19:48)</a>:</h4>
<p>not sure <span class="user-mention" data-user-id="232957">@Jack Huey</span> if this is what you were thinking</p>



<a name="184939543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/Changing%20CHALK_SOLVER_MAX_SIZE/near/184939543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/Changing.20CHALK_SOLVER_MAX_SIZE.html#184939543">(Jan 06 2020 at 19:51)</a>:</h4>
<p>Yep, basically. Just right now that's not what is done</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>